home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- *
- * Copyright (c) 1993 Silicon Graphics, Inc.
- * All Rights Reserved
- *
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI
- *
- * The copyright notice above does not evidence any actual of intended
- * publication of such source code, and is an unpublished work by Silicon
- * Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is
- * the property of Silicon Graphics, Inc. Any use, duplication or
- * disclosure not specifically authorized by Silicon Graphics is strictly
- * prohibited.
- *
- * RESTRICTED RIGHTS LEGEND:
- *
- * Use, duplication or disclosure by the Government is subject to
- * restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
- * Technical Data and Computer Software clause at DFARS 52.227-7013,
- * and/or in similar or successor clauses in the FAR, DOD or NASA FAR
- * Supplement. Unpublished - rights reserved under the Copyright Laws of
- * the United States. Contractor is SILICON GRAPHICS, INC., 2011 N.
- * Shoreline Blvd., Mountain View, CA 94039-7311
- **************************************************************************
- *
- * File: impverbatim.c
- *
- * Description: Converts an SGI Image file to VERBATIM storage format.
- *
- * Uasge: impverbatim inimage outimage
- *
- **************************************************************************/
-
-
- #ident "$Revision: 1.1 $"
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "imp.h"
-
-
- /**************************************************************************
- *
- * Function: main
- *
- * Description: Program entry point
- *
- * Parameters:
- * argc (I) - number of command line arguments
- * argv (I) - command line arguments
- *
- * Return: 0 if no errors. 1 if errors.
- *
- **************************************************************************/
-
- int main(int argc, char *argv[])
- {
- IMPImage *inImage, *outImage;
- register int y, chan;
- register int ysize, numChan;
- short *rowbuf;
- char *pname;
-
- /*
- * Extract the program name
- */
- pname = ((pname = strrchr(argv[0], '/')) == NULL) ? argv[0]: pname + 1;
-
- /*
- * Check the arg count
- */
- if (argc < 3) {
- fprintf(stderr, "Usage: %s inimage outimage\n", pname);
- exit(1);
- }
-
- /*
- * Open the input image and the output image
- */
- if ((inImage = impOpen(argv[1], "r")) == NULL ) {
- impPerror(pname);
- exit(1);
- }
- rowbuf = (short*)malloc(impXSize(inImage) * sizeof(short));
- ysize = impYSize(inImage);;
- numChan = impNumChannels(inImage);
- if ((outImage = impOpen(argv[2], "w",
- impMakeRasterType(IMP_RASTER_ENC_VERBATIM, impRasterBPP(inImage)),
- impDimension(inImage),
- impXSize(inImage),
- ysize,
- numChan,
- impImageType(inImage),
- impName(inImage))) == NULL) {
- impPerror(pname);
- exit(1);
- }
-
- /*
- * Convert the image
- */
- for (chan = 0; chan < numChan; chan++)
- for (y = 0; y < ysize; y++) {
- if (impReadRow(inImage, rowbuf, y, chan) < 0) {
- impPerror(pname);
- exit(1);
- }
- if (impWriteRow(outImage, rowbuf, y, chan) < 0) {
- impPerror(pname);
- exit(1);
- }
- }
-
- /*
- * Close up all images and free storage
- */
- free(rowbuf);
- if (impClose(inImage) < 0) {
- impPerror(pname);
- exit(1);
- }
- if (impClose(outImage) < 0) {
- impPerror(pname);
- exit(1);
- }
-
- return 0;
- }
-